<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>uni-app-web-view</title>
    <style type="text/css">
      .btn {
        display: block;
        margin: 20px auto;
        padding: 5px;
        background-color: #007aff;
        border: 0;
        color: #ffffff;
        height: 40px;
        width: 200px;
      }

      .btn-red {
        background-color: #dd524d;
      }

      .btn-yellow {
        background-color: #f0ad4e;
      }
    </style>
  </head>
  <body>
    <div class="btn-list">
      <button class="btn" type="button" data-action="navigateTo">navigateTo</button>
      <button class="btn" type="button" data-action="redirectTo">redirectTo</button>
      <button class="btn" type="button" data-action="navigateBack">navigateBack</button>
      <button class="btn" type="button" data-action="reLaunch">reLaunch</button>
      <button class="btn btn-red" type="button" data-action="switchTab">switchTab</button>
      <button class="btn btn-yellow" type="button" data-action="postMessage">postMessage</button>
      <button class="btn btn-yellow" type="button" data-action="getEnv">getEnv</button>
    </div>
    <!-- 微信 JS-SDK 如果不需要兼容小程序，则无需引用此 JS 文件 -->
    <!-- <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script> -->
    <!-- uni 的 SDK -->
    <script type="text/javascript" src="https://gitee.com/dcloud/uni-app/raw/master/dist/uni.webview.1.5.2.js"></script>
    <script type="text/javascript">
      document.addEventListener('UniAppJSBridgeReady', function() {
        document.querySelector('.btn-list').addEventListener('click', function(evt) {
          var target = evt.target;
          if (target.tagName === 'BUTTON') {
            console.log(target)
            var action = target.getAttribute('data-action');
            switch (action) {
              case 'switchTab':
                uni.navigateTo({
                	url:'/pages/message/addressList/index?isType=' + 'radio'
                })
                break;
              case 'navigateBack':
                uni.navigateBack({
                  delta: 1
                });
                break;
              case 'postMessage':
                uni.postMessage({
                  data: {
                    action: 'postMessage'
                  }
                });
                break;
              case 'getEnv':
                uni.getEnv(function(res) {
                  alert('当前环境：' + JSON.stringify(res));
                });
                break;
              default:
                uni[action]({
                  url: '/pages/component/button/button'
                });
                break;
            }
          }
        });
      });
	  function getUniAppMessage(res) {
	  
		alert(JSON.stringify(res));
	  
	  }
    </script>
  </body>
</html>
